package bookstudytest.singleton;


/**
 * @author Lee
 * @Date: 2018/6/11 10:26
 * @Description: 懒汉模式的单例类 线程不安全
 */
public class LazyDemo {
    private LazyDemo() {
        System.out.println("你开始了？");
    }

    public static LazyDemo lazyDemo = null;

    public static LazyDemo getInstance() {
//        当多个线程同时进行到这个步骤，判定都为null，则都会生成新的实例
        if (lazyDemo == null){
            lazyDemo = new LazyDemo();
            System.out.println(lazyDemo);
        }
        return lazyDemo;
    }
}
